package com.aaa.controller.fpa;

import com.aaa.controller.BaseController;
import com.aaa.entity.PageSortEntity;
import com.aaa.entity.Result;
import com.aaa.entity.fpa.PersonalityEntity;
import com.aaa.service.fpa.PersonalityService;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：chenang（731712841@qq.com）
 * @date ：Created in 2022/8/30 11:43
 * @description：性格测试controller层 tbl_question_fpa
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/fpa")
public class PersonalityController extends BaseController {
    @Autowired
    PersonalityService personalityService;
    @RequestMapping(value="personalityAllfpa.do",method = RequestMethod.GET)
    public Result personalityAllfpa(PageSortEntity pageSortEntity ,PersonalityEntity personalityEntity){
        Page page = personalityService.queryPersonalitAlla(pageSortEntity, personalityEntity);
        return success(page.getResult(),page.getTotal());
    }
    @RequestMapping(value ="addpersonality.do",method = RequestMethod.POST)
    public Result addpersonality(PersonalityEntity personalityEntity){
        int i = personalityService.addPersonalit(personalityEntity);
        if(i>0){
            return success("添加成功");
        }else {
            return success("添加失败");
        }
    }
    @RequestMapping(value = "delpersonality.do",method = RequestMethod.POST)
    public Result delpersonality(int[] id){
        int i = personalityService.delPersonalit(id);
        if(i>0){
            return success("删除成功");
        }else {
            return success("删除失败");
        }
    }
    @RequestMapping("UpdatePersonality.do")
    public Result updatePersonality(PersonalityEntity personalityEntity){
        int i = personalityService.updatePersonalit(personalityEntity);
        if(i>0){
            return success("修改成功");
        }else {
            return success("修改失败");
        }
    }
    @RequestMapping("repetitionName.do")
    public Result repetitionName(PersonalityEntity personalityEntity){
        int i = personalityService.repetitionName(personalityEntity);
        if(i>0){
            return success("题目以添加");
        }else {
            return fail("");
        }
    }

}
